#pragma once
#include <iostream>
#include <pthread.h>
class myMtx
{
public:
    myMtx(pthread_mutex_t &mtx) : _mtx(mtx)
    {
        pthread_mutex_lock(&_mtx);
        std::cout << "加锁" << std::endl;
    }
    ~myMtx()
    {
        pthread_mutex_unlock(&_mtx);
        std::cout << "解锁" << std::endl;
    }

private:
    pthread_mutex_t &_mtx;
};